/* eslint-disable class-methods-use-this */
import {
  post,
  get,
  put,
  _delete,
} from '@/lin/plugins/axios'

// 我们通过 class 这样的语法糖使模型这个概念更加具象化，其优点：耦合性低、可维护性。
class Facility {
  async getFacilityList(page, limit, info) {
    const res = await get(`v1/facility?page=${page}&limit=${limit}`, info)
    return res
  }

  async getFacilityAll(info) {
    const res = await get('v1/facility_all', info)
    return res
  }

  async getFacilityInfo(id) {
    const res = await get(`v1/facility/${id}`)
    return res
  }

  async createFacility(info) {
    const res = await post('v1/facility', info)
    return res
  }

  async updateFacility(info) {
    const res = await put('v1/facility', info)
    return res
  }

  async deleteFacility(id) {
    const res = await _delete(`v1/facility/${id}`)
    return res
  }

  async getFacilitySortList(page, limit, info) {
    const res = await get(`v1/facility_sort?page=${page}&limit=${limit}`, info)
    return res
  }

  async getFacilitySortAll(info) {
    const res = await get('v1/facility_sort_all', info)
    return res
  }

  async getFacilitySortInfo(id) {
    const res = await get(`v1/facility_sort/${id}`)
    return res
  }

  async createFacilitySort(info) {
    const res = await post('v1/facility_sort', info)
    return res
  }

  async updateFacilitySort(info) {
    const res = await put('v1/facility_sort', info)
    return res
  }

  async deleteFacilitySort(id) {
    const res = await _delete(`v1/facility_sort/${id}`)
    return res
  }
}

export default new Facility()
